package com.yun.zf.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yun.zf.common.admin.dto.customer.CustomerInfoDto;
import com.yun.zf.common.admin.dto.customer.CustomerListDto;
import com.yun.zf.common.admin.model.customer.CustomerReqMo;
import com.yun.zf.common.app.domain.ZfCustomerRequirement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 客户资源需求表 Mapper 接口
 * </p>
 *
 * @author cj
 * @since 2021-03-30
 */
@Mapper
public interface ZfCustomerRequirementMapper extends BaseMapper<ZfCustomerRequirement> {

    @Select("<script>" +
            " SELECT r.id,r.customer_id,  r.demand_type,r.area,r.budget,r.unit,r.fixtures,r.bedrooms,r.floor,r.buid_year,r.rent_type,r.remark from zf_customer_requirement r WHERE customer_id=#{customerId} and city_code=#{cityCode} and province_code=#{proCode} " +
            "</script>")
    List<CustomerReqMo> getRequirement(Long proCode, Long cityCode, Long customerId);


    @Select("<script>" +
            " SELECT r.id,r.customer_id,  r.demand_type,r.area,r.budget,r.unit,r.fixtures,r.bedrooms,r.floor,r.buid_year,r.rent_type,r.remark from zf_customer_requirement r WHERE id=#{requirementId} and city_code=#{cityCode} and province_code=#{proCode} " +
            "</script>")
    CustomerReqMo requirement(Long proCode, Long cityCode, Long requirementId);


    @Select("<script>" +
            " SELECT r.id,r.customer_id,  r.demand_type,r.area,r.budget,r.unit,r.fixtures,r.bedrooms,r.floor,r.buid_year,r.rent_type,r.remark from zf_customer_requirement r WHERE customer_id=#{customerId} and city_code=#{cityCode} and province_code=#{proCode} " +
            "</script>")
    List<CustomerInfoDto> getReqTempt(Long proCode, Long cityCode, Long customerId);

    @Select("<script>" +
            " SELECT  customer_id, demand_type, area,budget,unit,bedrooms,remark,modified_time FROM zf_customer_requirement r \n" +
            " WHERE r.customer_id=#{customerId} AND r.city_code=#{cityCode} and r.province_code=#{proCode} ORDER BY modified_time DESC LIMIT 1" +
            "</script>")
    CustomerListDto getReqBasic(Long proCode, Long cityCode,  Long customerId);
}
